<template>
    <div class="recommend">
        <scroll class="recommend-content" :data="discList" ref="scroll">
            <div>
                <div class="slider-wrapper" v-if="recommends.length">
                    <slider >
                        <div v-for="(item , index) in recommends" :key="index">
                            <a :href="item.linkUrl">
                                <img  class="needsclick" :src="item.picUrl" alt="">
                            </a>
                        </div>
                    </slider>
                </div>
                <div class="recommend-list">
                <h1 class="list-title">热门歌单推荐</h1>
                <ul>
                    <li v-for="(item,index) in discList" :key="index">
                        <div class="div1">
                            <img v-lazy="item.imgurl" alt="">
                        </div>
                        <div class="div2">
                            <span class="span1">{{item.dissname}}</span>
                            <span class="span2">{{item.creator.name}}</span>
                        </div>
                    </li>
                </ul>
                <div class="loading-container" v-show="!discList.length">
                    <loading></loading>
                </div>
                </div>
            </div>
        </scroll>
    </div>
</template>
<script>
import Scroll from '@/base/scroll/scroll'
import {getRecommend,getDiscList} from '@/api/recommend'
import {ERR_OK} from '@/api/config'
import Slider from '@/base/slider/slider'
import loading from '@/base/loading/loadind'
export default {
    data(){
        return{
            inde:2,
            recommends:[],
            discList:[]
        }
    },
    created(){
        this._getDisclist();
        this._getRecommend();
        
        
    },
    methods:{
        _getRecommend(){
            getRecommend().then((res)=>{
                if(res.code===ERR_OK){
                    this.recommends=res.data.slider;
                }
            })
        },
        _getDisclist(){
            getDiscList().then((res)=>{
                if(res.code==ERR_OK){
                    this.discList=res.data.list;
                }
            })
        }
    },
    components:{
        Slider,
        Scroll,
        loading
    }
}
</script>
<style scoped lang="less">
.recommend{
    margin-top: 3px;
    width: 100%;
    background-color: #fff;
    // position: absolute;
    position: fixed;
    top: 90px;
    bottom: 0px;
    overflow: hidden;
    .recommend-content{
        // height: 100%;
        width: 100%;
        height: 100%;
        overflow: hidden;
        position: absolute;
        // overflow: hidden;
        .slider-wrapper{
            position: relative;
            width: 100%;
            overflow: hidden;
        }
    }
    ul{
        width: 100%;
        li{
            width:100%;
            height: 80px;
            font-size: 16px;
            margin-bottom: 20px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            .div1{
                width: 60px;
                height: 60px;
                margin-left: 20px;
                border-radius: 5px;
                overflow: hidden;
            }
            .div2{
                display: flex;
                justify-content: center;
                align-items: center;
                flex-direction: column;
                text-align: left;
                margin-left: 20px;
                span{
                    display: block;
                    height: 40px;
                    line-height: 40px;
                    width: 100%;
                    color: #727272;
                
                }
                span:last-child{
                    font-size: 12px;
                    color: #d1d1d1;
                }
            }
        }
    }
}
    a{
        display: block;
        width: 100%;
        height: 100%;
    }
    .list-title{
        text-align: center;
        display: block;
        height: 40px;
        line-height: 40px;
        color: #E54D18;
    }
    .loading-container{
        position: absolute;
        width: 100%;
        top: 60%;
        transform: translateY(-50%)
    }
</style>

